package org.zpmis.domain.user.vo;

import lombok.Data;
import org.zpmis.domain.user.model.SysUser;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.List;


@Data
public class SysUserListVo {
    /**
     * 员工id
     */
    private Long id;

    /**
     * 用户名
     */
    private String userName;

    /**
     * 用户密码
     */
    private String password;

    /**
     * 上一次登录时间
     */
    private String lastLoginTime;

    /**
     * 创建时间
     */
    private String createTime;

    /**
     * 修改时间
     */
    private String updateTime;

    /**
     * 创建人
     */
    private Long createUser;

    /**
     * 修改人
     */
    private Long updateUser;

    /**
     * 用户权限
     */
    private String roleIds;

    public SysUserListVo(SysUser sysUser){
        this.id = sysUser.getId();
        this.userName = sysUser.getUserName();
        this.lastLoginTime = sysUser.getLastLoginTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(sysUser.getLastLoginTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.createUser = sysUser.getCreateUser();
        this.updateUser = sysUser.getUpdateUser();
        this.createTime =sysUser.getCreateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(sysUser.getCreateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
        this.updateTime = sysUser.getUpdateTime() == null ? "" : LocalDateTime.ofInstant(Instant.ofEpochMilli(sysUser.getUpdateTime()), ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }
}
